package sicnu.cs.ich.api.common.enums;


import org.apache.logging.log4j.util.Strings;

import java.util.NoSuchElementException;

/**
 * @author CaiKe
 */

public enum FileEnum {
    // 上传文件前缀字段
    CERT("cert/", "认证相关"),
    ICH("ich/", "非遗相关图片"),
    USER_AVATER("user/avater/","头像"),
    ACTIVITY_COVER_IMG("activity/cover/","活动封面")
    ;
    String value;
    String description;

    FileEnum() {
    }

    FileEnum(String value, String description) {
        this.value = value;
        this.description = description;
    }

    public String getValue() {
        return value;
    }

    public String getDescription() {
        return description;
    }

    @Override
    public String toString() {
        return "ConfigEnum{" +
                "value='" + value + '\'' +
                "} " + super.toString();
    }

    public static FileEnum toEnum(String value) {
        if (Strings.isBlank(value))
            throw new IllegalArgumentException("value不能为空或null");

        for (FileEnum configEnum : FileEnum.values()) {
            if (configEnum.getValue().equals(value)) {
                return configEnum;
            }
        }
        throw new NoSuchElementException("无 " + value + " 对应的ConfigEnum");
    }
}
